using System;
using System.Collections.Generic;
using System.Text;

using System.Xml.Serialization;

namespace XMIAddin.Xmi
{
/*    [Serializable,
     XmlInclude(typeof(UmlDataTypeTypeReference)), 
     XmlInclude(typeof(UmlClassTypeReference))]*/
    public class UmlTypeReference
    {
        [XmlAttribute("xmi.idref")]
        public Guid Id;

        public static UmlTypeReference Create(UmlModelElement refFor)
        {
            UmlTypeReference result = null;

            if (refFor is UmlDataType)
            {
                result = new UmlDataTypeTypeReference();
            }
            else if (refFor is UmlClassifier)
            {
                result = new UmlClassTypeReference();
            }
            else if (refFor is UmlStereotype)
            {
                result = new UmlStereotypeReference();
            }

            result.Id = refFor.Id;
            return result;
        }
    }

    [Serializable]
    public class UmlClassTypeReference : UmlTypeReference
    {
    }

    [Serializable]
    public class UmlStereotypeReference : UmlTypeReference
    {
    }

    [Serializable]
    public class UmlDataTypeTypeReference : UmlTypeReference
    {
    }

    [Serializable,
     XmlInclude(typeof(UmlDataTypeTypeReference)),
     XmlInclude(typeof(UmlClassTypeReference)),
     XmlInclude(typeof(UmlStereotypeReference))]
    public class UmlTypedElementType
    {
        [XmlElement(typeof(UmlDataTypeTypeReference), ElementName = "DataType"), //, Namespace = "org.omg.xmi.namespace.UML"),
         XmlElement(typeof(UmlClassTypeReference), ElementName = "Class"),
         XmlElement(typeof(UmlStereotypeReference), ElementName = "Stereotype")] //, Namespace = "org.omg.xmi.namespace.UML")]
        public UmlTypeReference Type = null;

        public static UmlTypedElementType Create(UmlModelElement refFor)
        {
            UmlTypedElementType result = new UmlTypedElementType();
            result.Type = UmlTypeReference.Create(refFor);
            return result;
        }

        //public List<UmlTypeReference> TypeData = null;

        //internal UmlTypeReference Type
        //{
        //    set { TypeData = new List<UmlTypeReference>(); TypeData.Add(value); }
        //}
    }
}
